<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <link href="css/footer.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    <style>
        body {
            background: url('./img/timg2.png') no-repeat center center fixed;
            background-size: cover;
            color: #fff;
            font-family: 'San Francisco', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }

        /* 注册表单容器 */
        .register-container {
            max-width: 400px;
            margin: 50px auto;
            padding: 10px;
            border: none;
            border-radius: 20px;
            transition: all 0.3s ease-in-out;
            background: rgba(0, 0, 0, 0.6); /* 深色背景，透明效果 */
            box-shadow: 0 5px 40px rgba(0, 0, 0, 0.4);
        }
        .register-container:hover{
            transform: translateY(-10px);
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); /* 悬浮时增加阴影 */
        }

        .register-container h1 {
            text-align: center;
            font-size: 36px;
            color: #fff;
            font-weight: bold;
            letter-spacing: 2px;
            margin-bottom: 30px;
        }

        /* 输入框样式 */
        .form-control {
            border-radius: 12px;
            padding: 10px;
            border: 1px solid #474646;
            background-color: rgba(255, 255, 255, 0.2);
            color: #fff;
            transition: all 0.3s ease;
        }

        .form-control:focus {
            border-color: #66afe9;
            box-shadow: 0 0 8px rgba(102, 175, 233, 0.6);
            background-color: rgba(255, 255, 255, 0.4);
        }

        /* 标签样式 */
        .form-label {
            font-weight: bold;
            font-size: 16px;
            color: #bbb;
        }


        /* 按钮样式 */
        .btn-primary {
            background: linear-gradient(to right, rgba(99, 65, 255, 0.89), #2575fc);
            border: none;
            border-radius: 30px;
            padding: 12px 30px;
            font-size: 16px;
            font-weight: bold;
            text-transform: uppercase;
            letter-spacing: 1px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
            transition: background 0.6s ease, transform 0.3s ease, box-shadow 0.3s ease-in-out;
        }

        .btn-primary:hover {
            background: linear-gradient(to right, #2575fc, rgba(99, 65, 255, 0.89));
            transform: translateY(-2px);
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
        }

        .btn-primary:active {
            transform: translateY(2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }

        /* 错误信息样式 */
        .error-message {
            color: red;
            font-size: 14px;
            display: none;
        }

        /* 链接样式 */
        .d-block.text-center.mt-3 {
            font-weight: bold;
            background-image: linear-gradient(90deg, rgba(99, 65, 255, 0.89), rgba(255, 99, 255, 0.89)); /* 渐变效果 */
            background-size: 200% auto;
            color: transparent; /* 文字颜色透明，显示渐变效果 */
            background-clip: text; /* 使渐变应用于文字 */
            transition: background-position 0.3s ease, transform 0.3s ease;
        }

        .d-block.text-center.mt-3:hover {
            background-position: right center; /* 鼠标悬停时渐变方向改变 */
            transform: translateY(-3px);
        }

        /* 页脚 */
        footer {
            text-align: center;
            margin-top: 20px;
            font-size: 14px;
            color: #bbb;
        }

        footer a {
            color: #bbb;
            text-decoration: none;
        }

        footer a:hover {
            color: #fff;
        }
    </style>

</head>

<body>
<div class="register-container">
    <h1>REGISTER</h1>
    <form id="register-form">
        <div class="mb-3">
            <label for="phone" class="form-label">手机号</label>
            <div class="input-group">
                <input type="text" id="phone" class="form-control" placeholder="11位手机号" />
                <button class="btn btn-primary" type="button">发送</button>
            </div>
            <div class="error-message" id="phone-error">请输入正确的11位手机号</div>
        </div>

        <div class="mb-3">
            <label for="code" class="form-label">验证码</label>
            <input type="text" id="code" class="form-control" placeholder="4位验证码" />
            <div class="error-message" id="code-error">请输入4位验证码</div>
        </div>

        <div class="mb-3">
            <label for="password" class="form-label">密码</label>
            <input type="password" id="password" class="form-control" placeholder="6位密码" />
            <div class="error-message" id="password-error">请输入至少6位密码</div>
        </div>

        <div class="mb-3">
            <label for="confirm-password" class="form-label">确认密码</label>
            <input type="password" id="confirm-password" class="form-control" placeholder="请确认密码" />
            <div class="error-message" id="confirm-password-error">两次密码输入不一致</div>
        </div>

        <div class="mb-3 agreement">
            <input type="checkbox" id="agreement" class="form-check-input" />
            <label for="agreement" class="ms-2">同意XXX协议</label>
            <div class="error-message" id="agreement-error">请同意协议</div>
        </div>

        <button type="button" id="submit-button" class="btn btn-primary w-100">注册</button>
        <a href="login.html" class="d-block text-center mt-3">已有账号？登录</a>
    </form>
</div>
<footer>
    Copyleft © 2024 uu. All rights reversed. 😉
</footer>
<script>
    $(document).ready(function () {
        //定义跳转到registerok.html
        function goregok() {
            window.location.href = "registerok.html";
        }

        $('#submit-button').click(function () {
            let valid = true;

            // 获取表单值
            const phone = $('#phone').val();
            const code = $('#code').val();
            const password = $('#password').val();
            const confirmPassword = $('#confirm-password').val();
            const agreement = $('#agreement').is(':checked');

            // 验证手机号
            if (!/^\d{11}$/.test(phone)) {
                valid = false;
                $('#phone-error').fadeIn();
            } else {
                $('#phone-error').fadeOut();
            }

            // 验证验证码
            if (!/^\d{4}$/.test(code)) {
                valid = false;
                $('#code-error').fadeIn();
            } else {
                $('#code-error').fadeOut();
            }

            // 验证密码
            if (password.length < 6) {
                valid = false;
                $('#password-error').fadeIn();
            } else {
                $('#password-error').fadeOut();
            }

            // 验证确认密码
            if (password !== confirmPassword) {
                valid = false;
                $('#confirm-password-error').fadeIn();
            } else {
                $('#confirm-password-error').fadeOut();
            }

            // 验证协议
            if (!agreement) {
                valid = false;
                $('#agreement-error').fadeIn();
            } else {
                $('#agreement-error').fadeOut();
            }

            // 如果验证通过
            if (valid) {
                goregok();
                // alert('注册成功！');
            }
        });
    });
</script>
</body>

</html>
